import { OperateBase } from '../../common/operate-base';
import { ExecuteRecord } from '../../../cors/execute-record';
export class Forward extends OperateBase {
    protected executeRecord: ExecuteRecord;
    protected container: HTMLElement;
    constructor() {
        super();
    }
    public selectChange() {

    }
    public getDom() {
        this.container = document.createElement('div');
        this.container.setAttribute('class', this.containerClassName);
        this.container.innerHTML=`<span class="z-tools-icon icon iconfont icon-qianjin-shi"></span>`;
        return this.container;
    }
    public afterDomInit() {
        this.executeRecord = this.zTableInstance.pluginManager.getPlugin(ExecuteRecord.pluginName);
        this.zTableInstance.getHook().afterCommandExcute.add(this.checkIsDisabled.bind(this));
        this.checkIsDisabled();
        (this.container.querySelector('.icon-qianjin-shi') as HTMLElement).addEventListener('click', () => {
            let ele = this.container.querySelector('.icon-qianjin-shi') as HTMLElement;
            if(ele.classList.contains('z-table-icon-disabled')) {
                return;
            }
            this.executeRecord.nextDo();
        });
    }
    public checkIsDisabled():void {
        let ele = this.container.querySelector('.icon-qianjin-shi') as HTMLElement;
        if(this.executeRecord.canNextDo()) {
            ele.classList.remove('z-table-icon-disabled');
        } else {
            ele.classList.add('z-table-icon-disabled');
        }
    }
}